<template>
  <pro-dialog class="photos" ref="browseTplDom" width="710" :nopadding="true" title="报告预览">
    <div class="model-box modal-tpl" style="padding: 0 24px 24px">
      <YsRow>
        <div class="photos-title  border_style">
          <p class="text_01">X射线探伤检测报告</p>
          <div class="report_code text_01">
            <label>报告编号</label>
            <div class="code_rigth"></div>
          </div>
        </div>
        <div class="photos-table border_style">
          <div class="border_style photos-row" v-for="(item,index)  in templateBean.templateFields">
            <div class="photos-col photos-col1 border_style" :title="item.field_name">{{item.field_name}}</div>
            <div class="photos-col photos-col2" :title="item.field_default_val">{{item.field_default_val}}</div>
          </div>
          <div class="border_style photos-row" v-if="templateBean.templateFields&&templateBean.templateFields.length% 2 != 0">
            <div class="photos-col photos-col1"></div>
            <div class="photos-col photos-col2"></div>
          </div>
        </div>
      </YsRow>
    </div>
  </pro-dialog>
</template>
<script>
import { mapActions } from "vuex";
export default {
  name: 'browseTpl',
  data() {
    return {
      templateBean: []
    }
  },
  methods: {
    ...mapActions(["getTemplateDetailAPI"]),
    // 获取列表数据
    getTempList(id) {
      this.$refs.browseTplDom.show()
      this.getTemplateDetailAPI({ template_id: id }).then(res => {
        let { data, msg, scode, status } = res;
        if (status === "ok") {
          this.templateBean = data.templateBean
        } else {
          this.templateBean = this.$options.data().templateBean
        }
      })
    },
  }
}
</script>
<style scoped lang='less'>
.photos {
  /deep/ .ivu-modal-header {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }
  /deep/ .ivu-modal-close {
    right: 18px;
  }
  .photos-title {
    height: 93px;
    width: 100%;
    border: 1px solid #e1e6f0;
    border-bottom: none;
    line-height: 93px;
    position: relative;
    p {
      text-align: center;
      font-size: 20px !important;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      font-size: 16px;
    }
    span {
      position: absolute;
      right: 16px;
      bottom: 0px;
      height: 30px;
      line-height: 30px;
    }
  }
  .photos-table {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 58px;
    border: 1px solid #e1e6f0;
    max-height: 60vh;
    min-height: 10vh;
    overflow: auto;
    .photos-row {
      margin-bottom: -1px;
      display: flex;
    }
    .photos-row:nth-child(odd) {
      border-right: 1px solid transparent;
      border-bottom: 1px solid transparent;
    }
    .photos-row:nth-child(even) {
      border-bottom: 1px solid transparent;
    }
    .photos-col {
      width: 50%;
      max-width: 163px;
      height: 100%;
      line-height: 58px;
      padding-left: 32px;
      // text-align: center;
      word-break: keep-all;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .photos-col1 {
      border-right: 1px solid #e1e6f0;
    }
  }
  .report_code {
    position: absolute;
    right: 16px;
    bottom: 6px;
    height: 30px;
    line-height: 30px;
    font-size: 16px;
    display: flex;
    .code_rigth {
      width: 150px;
    }
  }
}
</style>